package com.zhuozhou.jdyc.main.meinfo.adapter;

import android.content.Context;

import com.bumptech.glide.Glide;
import com.zhuozhou.jdyc.R;
import com.zhuozhou.jdyc.base.BaseRecyclerViewAdapter;
import com.zhuozhou.jdyc.base.BaseViewHolder;
import com.zhuozhou.jdyc.databinding.AdapterOrderItemBinding;
import com.zhuozhou.jdyc.main.meinfo.bean.BasicsMyPayBean;

/**
 * Create by CherishTang on 2020/3/27 0027
 * describe:首页菜单adapter
 */
public class OrderItemAdapter extends BaseRecyclerViewAdapter<BasicsMyPayBean.ListBeanX.ListBean, AdapterOrderItemBinding> {
    public OnItemButtonClickListener mOnItemButtonClickListener;

    public OrderItemAdapter(Context context) {
        super(context);
    }

    int shoppingtype, status, usertype;

    @Override
    protected int getLayoutId() {
        return R.layout.adapter_order_item;
    }

    @Override
    public void onBindViewHolder(BaseViewHolder baseViewHolder, int pos) {
        super.onBindViewHolder(baseViewHolder, pos);
    }

    @Override
    public void onBindHolder(BaseViewHolder<AdapterOrderItemBinding> holder, int pos) {
        Glide.with(mContext).load(mList.get(pos).getProperty().getSpec_image()).into(holder.getBinding().imageShop);
        holder.getBinding().setOrder(mList.get(pos));
        holder.getBinding().setShoppingtype(shoppingtype);
        holder.getBinding().setStatus(status);
        holder.getBinding().setUsertype(usertype);
        holder.getBinding().tvPrintComments.setOnClickListener(v -> {
            if (mOnItemButtonClickListener != null)
                mOnItemButtonClickListener.OnItemButtonClick(pos, 7);
        });
        holder.getBinding().tvToVerification.setOnClickListener(v -> {
            if (mOnItemButtonClickListener != null)
                mOnItemButtonClickListener.OnItemButtonClick(pos, 8);
        });
        holder.getBinding().tvReturnRequest.setOnClickListener(v -> {
            if (mOnItemButtonClickListener != null)
                mOnItemButtonClickListener.OnItemButtonClick(pos, 9);
        });
    }

    public void setInfo(int shoppingtype, int status, int usertype) {
        this.shoppingtype = shoppingtype;
        this.status = status;
        this.usertype = usertype;
    }

    public void setOnItemButtonClickListener(OnItemButtonClickListener l) {
        mOnItemButtonClickListener = l;
    }

    public interface OnItemButtonClickListener {
        void OnItemButtonClick(int pos, int type);
    }
}
